package org.dizem.util;

import sun.misc.BASE64Encoder;

import java.io.UnsupportedEncodingException;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;

/**
 * @author: dizem
 * @date: 11-6-26
 */
public class MD5Util {
	public static String encode(String s) {
		try {
			MessageDigest md5 = MessageDigest.getInstance("MD5");
			return new BASE64Encoder().encode(md5.digest(s.getBytes("utf-8")));

		} catch (NoSuchAlgorithmException e) {
			e.printStackTrace();
		} catch (UnsupportedEncodingException e) {
			e.printStackTrace();
		}
		return null;
	}
}
